<div id="tab-system" class="HuiTab">
	<div class="tabBar cl">
		<span class="current">栏目列表</span>
		<span onclick="HtmlRender('${BASE}/admin/cms/column/add')">添加栏目</span>
	</div>
</div>
<form action="${BASE}/admin/cms/column/updateSort" id="form_updateSort" method="post">
<div class="cl pd-5 bg-1 bk-gray mt-20"> 
	<span class="l">
		<a href="javascript:;" class="btn btn-primary size-S radius btn_submit"><i class="Hui-iconfont">&#xe6e2;</i> 保存排序</a>
	</span>
</div>
<div class="dataTables_wrapper no-footer">
<table class="table table-border table-bordered table-bg table-hover">
	<thead>
		<tr class="text-c">
	<th width="40">ID</th>
	<th width="150">栏目名称</th>
	<th width="100">排序</th>
	<th>href</th>
			<th width="284">操作</th>
		</tr>
	</thead>
	<tbody>
	<% for(obj in list){ %>
		<tr class="text-c" style="background-color:#EEE">
			<td>${obj.id}</td>
			<td class="text-l">${obj.name}</td>
			<td>
			  <input type="hidden" name="ids" value="${obj.id}"/>
			  <input name="sorts" type="text" class="input-text text-c" value="${obj.sort}" datatype="n"></td>
			<td>${obj.href}</td>
			<td class="td-manage text-r">
				<a class="btn btn-success size-MINI" href="javascript:;" title="添加下级菜单" onclick="list_add('${obj.id}')"><i class="Hui-iconfont">&#xe604;</i> 添加下级菜单</a> 
				<a class="btn btn-primary size-MINI" href="javascript:;" title="添加文章" onclick="modal_add('${obj.id}')"><i class="Hui-iconfont">&#xe616;</i> 添加文章</a> 
				<a class="btn btn-secondary size-MINI" href="javascript:;" title="编辑" onclick="list_edit('${obj.id}')"><i class="Hui-iconfont">&#xe6df;</i> 编辑</a> 
				<a class="btn btn-danger size-MINI" href="javascript:;" title="删除" onclick="list_del('${obj.id}')"><i class="Hui-iconfont">&#xe6e2;</i> 删除</a>
			</td>
		</tr>
		<% for(child in obj.childList){ %>
			<tr class="text-c">
				<td>${child.id}</td>
				<td class="text-l">${childLP.last?"	      └─ ":"	      ├─ "}${child.name}</td>
				<td>
					<input type="hidden" name="ids" value="${child.id}"/>
					<input name="sorts" type="text" class="input-text text-c" value="${child.sort}" datatype="n">
				</td>
				<td>${child.href}</td>
				<td class="td-manage text-r">
					<a class="btn btn-primary size-MINI" href="javascript:;" title="添加文章" onclick="modal_add('${child.id}')"><i class="Hui-iconfont">&#xe616;</i> 添加文章</a> 
					<a class="btn btn-secondary size-MINI" href="javascript:;" title="编辑" onclick="list_edit('${child.id}')"><i class="Hui-iconfont">&#xe6df;</i> 编辑</a> 
					<a class="btn btn-danger size-MINI" href="javascript:;" title="删除" onclick="list_del('${child.id}')"><i class="Hui-iconfont">&#xe6e2;</i> 删除</a>
				</td>
			</tr>
		<% } %>
	<% } %>
	</tbody>
</table>
</div>
<div class="cl pd-5 bg-1 bk-gray"> 
	<span class="l">
		<a href="javascript:;" class="btn btn-primary size-S radius btn_submit"><i class="Hui-iconfont">&#xe6e2;</i> 保存排序</a>
	</span>
</div>
</form>
<script type="text/javascript">
function list_del(id){
	var select_ids = "";
	if(id){
		select_ids=id;
	}else{
	    $("input[name='table_checkbox_id']:checked").each(function(){
	    	select_ids+=$(this).val()+",";   
	    });
	    if(""==select_ids){
	    	layer.msg('请先选择要删除的数据！', {icon: 3,offset: '45px'});
	    	return false;
	    }
	}
	layer.confirm('确认删除所选记录?', {icon: 3, title:'警告'}, function(index){	    
	    layer.close(index);
	    HtmlRender("${BASE}/admin/cms/column/del",{ids:select_ids});
	});
}
function list_edit(id,state){
    HtmlRender("${BASE}/admin/cms/column/edit",{id:id});
}
function list_search(){
	var $form = $("#form_pager_search");
	var url = $form.attr('action');
	var $input  = $("<input type='hidden' name='_sbtn' value='true' />");
	$form.append($input);
    HtmlRender(url,$form.serializeArray());
}
function list_changeSize(size){
	$("#form_pager_search > [name='_p_pageSize']").val(size);
	var $form = $("#form_pager_search");
	var url = $form.attr('action');
    HtmlRender(url,$form.serializeArray());
}
function list_add(id){
	HtmlRender("${BASE}/admin/cms/column/add",{parentId:id});
}
function modal_add(id){
	$.post('${BASE}/admin/cms/column/addArticle', {columnId:id}, function(str){
	    layer.open({
	    	title:"在当前栏目添加文章",
	    	area: ['960px', '500px'],
	        type: 1,
	        content: str //注意，如果str是object，那么需要字符拼接。
	    });
	});
}
$(function(){
	$("#form_updateSort").Validform({
		btnSubmit:".btn_submit",
		ajaxPost:true,
		postonce:true,
		callback:function(data){
			$.Hidemsg();
			if("200"==data.retCode){
				layer.msg('保存成功！', {icon: 6,offset: '45px'});
			}else{
				layer.msg(data.retMsg, {icon: 5,offset: '45px'});
			}
		}
	});
});
</script>